/*
 * Created: Author: Aléx Carvalho / Date: Jan 23, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-06-04 21:24:45 -0300 (Thu, 04 Jun 2015) $
 */

package com.cpm.entities;

import com.cpm.entities.converters.ActionStatePersistenceConverter;
import com.cpm.entities.converters.FamilyPersistenceConverter;
import com.cpm.entities.converters.LocalDatePersistenceConverter;
import com.cpm.entities.id.IntegerId;
import com.cpm.entities.types.ActionStateType;
import com.cpm.entities.types.Family;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;

@Entity
public class Action extends IntegerId implements Identity<Action> {
    private static final long serialVersionUID = 6134414180953958880L;

    @Column(nullable = false)
    private Integer parentId;
    
    @Column(nullable = false)
    @Convert(converter = FamilyPersistenceConverter.class)
    private Family parentFamily;

    @Column(nullable = false)
    @Convert(converter = ActionStatePersistenceConverter.class)
    private ActionStateType state;
    
    @Column(nullable = false, length = 200)
    private String name;

    @Column(nullable = false)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtPlannedStart;

    @Column(nullable = false)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtPlannedEnd;

    @Column(nullable = false)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtRealStart;
    
    @Column(nullable = false)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtRealEnd;

    public Action() {}

    @Override
    public Family getFamily() { return Family.ACTION; }

    @Override
    public Action clone() {
        return null;
    }
    
    @Override
    public String toString() { return name; }
}
